
package communication;
import objects.Station;
import communication.pack.*;

/**
 *@author equipe SIMPACK 2005
 *This class represents a package and its current receiver during the communication
 *
 */

public class IdentifiedCurrentPackage{
	
	
	private Station currentStation; //la station receptrice ou emettrice du paquet
	private SMPackage currentPackage;//the package
	private boolean receiver;//indiquates if the current station is receiver or sender
	int weIdent; //identifiant de l'objet
	
	public static boolean RECEIVER=true;
	public static boolean SENDER=false;
	
	
	/**
	 * constructor
	 * @param s the current MobileStation who is receiving or sending the package
	 * @param p  the package which is received
	 * @param b the boolean
	 * @param wId the package identifier
	 */
	public IdentifiedCurrentPackage(Station s, SMPackage p, boolean b,int wId){
		currentStation = s;
		currentPackage = p;
		receiver = b;
		weIdent = wId;
		
		
	}

	/**
	 * @return
	 */
	public SMPackage getCurrentPackage() {
	    return currentPackage;
	}

	/**
	 * @return
	 */
	public Station getCurrentStation() {
		return currentStation;
	}

	/**
	 * @param package1
	 */
	public void setCurrentPackage(SMPackage package1) {
		currentPackage = package1;
	}

	/**
	 * @param station
	 */
	public void setCurrentStation(Station station) {
		currentStation = station;
	}

	/**
	 * @return
	 */
	public boolean isReceiver() {
		return receiver;
	}

	/**
	 * @param b
	 */
	public void setReceiver(boolean b) {
		receiver = b;
	}

	/**
	 * @return
	 */
	public int getWeIdent() {
		return weIdent;
	}

	/**
	 * @param i
	 */
	public void setWeIdent(int i) {
		weIdent = i;
	}
    
    public String toString(){
	String s;
	if(this.receiver == IdentifiedCurrentPackage.RECEIVER){
	s = " receveur "+this.getCurrentStation().getName()+" \n"+
	    this.getCurrentPackage().toString();
	
	}
	else{
	    
	    s = " emmeteur "+this.getCurrentStation().getName()+" \n"+
		this.getCurrentPackage().toString();
	    
	}
	return s;
    }
    
}
